﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using QunYing.BLL;
using Spore.Validator;

namespace Client
{
    public partial class FrmRepay : BasePopForm
    {
        public DataRowView row = null;
        public FrmRepay()
        {
            InitializeComponent();
            if (GlobalInfo.UserLoginInfo.角色 == "平台管理员")
            {
                btnAdd.Visible = false;
            }
            this.NecessaryRemark(this.txtRepay);
            this.FormValidator.SetControlValitors(txtRepay, ValidatorDefaults.NotNull);
        }

        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (!this.FormValidator.ValidAll()) return;
            QunYing.BLL.LeaveMsg msg = new LeaveMsg();
            bool b = msg.ReplyMsg(row["ID"].ToString(), GlobalInfo.UserLoginInfo.用户ID,
                                  txtRepay.Text.Trim().Replace("\r\n", "<br/>"));
            if (b)
            {
                GlobalInfo.MsgBoxShow("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                FrmMsgManager.frm.QueryData();
                this.Close();
            }
            else
            {
                GlobalInfo.MsgBoxShowError("保存失败!");
            }
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void BindInfo()
        {
            txtUser.Text = row["用户姓名"].ToString();
            txtTime.Text = Convert.ToDateTime(row["留言时间"]).ToString("yyyy-MM-dd HH:mm:ss");
            txtContent.Text=row["留言内容"].ToString().Replace("<br/>","\r\n");
            txtRepay.Text = row["回复内容"].ToString().Replace("<br/>", "\r\n");
        }

        private void FrmRepay_Load(object sender, EventArgs e)
        {
            BindInfo();
        }
    }
}
